<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">

    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import adminRoles from '@/api/user/adminRoles'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'
import dictHelp from "@/utils/dicthelp.js";
const crudRef = ref()

const options = reactive({
  id: 'admin_roles',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: adminRoles.getList,
  add: {
    show: true,
    api: adminRoles.save,
    auth: ['user:adminRoles:save']
  },
  edit: {
    show: true,
    api: adminRoles.update,
    auth: ['user:adminRoles:update']
  },
  delete: {
    show: true,
    api: adminRoles.deletes,
    auth: ['user:adminRoles:delete']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "角色名",
    dataIndex: "name",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "标识",
    dataIndex: "slug",
    formType: "input",
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    showTime: true,
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    showTime: true,
  },
  {
    title: "创建人",
    dataIndex: "created_by",
    formType: "select",
    dict:dictHelp.customer,
    addDisplay: false,
    editDisplay: false,
  },
  {
    title: "权限",
    dataIndex: "roles",
    formType: "tree-select",
    dict:dictHelp.clientPermissions,
    multiple: true,
    hide: true,
  },
])
</script>
<script> export default { name: 'user:adminRoles' } </script>